import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { NzMessageService } from 'ng-zorro-antd/message';
import { AjaxServiceService } from 'src/services/AjaxService.service';
import { Md5 } from 'ts-md5';

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
  password:string="";
  constructor(private ajax:AjaxServiceService,private message: NzMessageService,private router: Router) { }

  ngOnInit() {
  }
  login():void{
    if(this.password==""){
      this.message.info('密码不能为空');
      return;
    }
    this.ajax.post("/Home/Login",{"password":Md5.hashStr(this.password).toString().toUpperCase()}).then((res:any)=>{

      if(res.code==0){
        localStorage.setItem("Authorization", res.data);
        this.router.navigate(["/home"]);
      }else{
        this.message.error(res.msg);
      }
    })

  }
}
